/**
 * HELIOS is a music library indexer.
 * It uses the Java ID3 Library by Jens Vonderheid 
 * @see http://www.vdheide.de/java_mp3/
 */
package indexer;

import java.io.File;

/**
 * @author Pascal de Vink
 * @version 0.2
 */
public class Dispatcher {

	public static String PATH = "c:\\helios\\";
	public static String SQLURL = "jdbc:mysql://localhost:3306/helios";
	public static String SQLUSER = "root";
	public static String SQLPASS = "";
	public static String LOG = "false";
	public static String LOGFILE = ""; 
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// Read the arguments for the settings file
		File src;
		if (args.length > 0)
		{
			src = new File(args[0]);
		} else {
			src = new File("settings.properties");
		}
		
		// Get all the necesary settings.
		Settings settings = new Settings();
		if (!settings.getSettings(src))
		{
			System.exit(1);
		}
		
		// Create a logger, if necesary
		if (Dispatcher.LOG.equals("true"))
		{
			Logger logg = new Logger(new File(Dispatcher.LOGFILE));
			logg.writeLine("Settings loaded, indexing started");
		}
		
		// Create a new thread to index the given path
		makeSearchThread();
	}
	
	private static void makeSearchThread()
	{
		File path = new File(Dispatcher.PATH);
		Search search = new Search(path);
		search.run();
	}

}
